/**
 * 
 */
package gisc.gov.vn.dev.gui;


import gisc.gov.vn.dev.core.IGiscSingletonInfo;
import gisc.gov.vn.dev.projectX.workspace.GiscConnectionBuilder;
import gisc.gov.vn.dev.projectX.workspace.GiscConnectionManager;
import gisc.gov.vn.dev.projectX.workspace.IGiscConnectionManager;

import java.awt.Color;
import java.awt.LayoutManager;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.ArrayList;

import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;

import org.apache.log4j.Logger;

import com.hardcode.driverManager.DriverLoadException;
import com.iver.andami.PluginServices;
import com.iver.andami.ui.mdiFrame.NewStatusBar;
import com.iver.andami.ui.mdiManager.WindowInfo;
import com.iver.cit.gvsig.SingleVectorialDBConnectionExtension;
import com.iver.cit.gvsig.fmap.drivers.DBException;
import com.iver.cit.gvsig.fmap.drivers.IVectorialDatabaseDriver;
import com.iver.cit.gvsig.fmap.drivers.db.utils.ConnectionWithParams;
import com.iver.cit.gvsig.fmap.drivers.db.utils.SingleVectorialDBConnectionManager;
import com.iver.cit.gvsig.fmap.layers.LayerFactory;

/**
 * @author HT
 *
 */
public abstract class GiscLoginPanel extends GiscPanel implements IGiscSingletonInfo{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static Logger logger = Logger.getLogger(GiscLoginPanel.class.getName());
	protected WindowInfo winfo = new WindowInfo(WindowInfo.MODALDIALOG); // MODAL only
    protected JButton btnCancel = null;
    protected JButton btnOk = null;
    protected JPanel pnlParam = null;
    protected JComboBox cbxDriver = null;
    protected JTextField txfPort = null;
    protected JTextField txfDatabase = null;
    protected JTextField txfUser = null;
    protected JPasswordField pwdPass = null;
    protected JLabel lblDriver = null;
    protected JLabel lblPort = null;
    protected JLabel lblDatabase = null;
    protected JLabel lblWarning = null;
    protected JLabel lblUser = null;
    protected JLabel lblPass = null;
    protected boolean blnOkPressed = false;
    protected JTextField txfUrl = null;
    protected JLabel lblUrl = null;
    protected JCheckBox ckbConnected = null;
    protected JLabel lblConnected = null;
    protected JLabel lblConnName = null;
    protected JTextField txfConnName = null;
    protected SingleVectorialDBConnectionExtension sglDBConnection;
    
    protected String strPrefixPgUrl="jdbc:postgresql://";
    protected String strDatabaseUrl="jdbc:postgresql://localhost/";   //  @jve:decl-index=0:
    protected String strHost="localhost";
    protected String strDatabaseUser="";  //  @jve:decl-index=0:
    protected String strDatabasePass="";  //  @jve:decl-index=0:
	protected JLabel lblCapsLock = null;

	protected String strDatabaseName="";
	protected String strConnName="";
	protected String strPort="5432";
	protected String strDriver="";
	protected Boolean blnIsConnected;
	protected Boolean exist=false;
	
	//quan ly ket noi
	protected IGiscConnectionManager connectionManager;
    /**
     * This method initializes
     *
     */
    public GiscLoginPanel(String title) {
        super();
        initialize(title);
        txfUser.requestFocus();
    }

//    public void showDialog() {
//    	PluginServices.getMDIManager().addCentredWindow(this);
//    }

    /**
     * This method initializes this
     *
     */
    private void initialize(String title) {
        winfo.setWidth(370);
        winfo.setHeight(317 - 25);
        winfo.setTitle(title); //Thông tin kết nối
       
        this.setSize(new java.awt.Dimension(360, 329));
        this.setLayout(null);
        this.add(getBtnCancel(), null);
        this.add(getBtnOk(), null);
        this.add(getPnlParam(), null);
       
    }

    public WindowInfo getWindowInfo() {
    	
        return winfo;
    }

    /**
     * This method initializes btnCancel
     *
     * @return javax.swing.JButton
     */
    protected JButton getBtnCancel() {
        if (btnCancel == null) {
            btnCancel = new JButton();
            btnCancel.setText(PluginServices.getText(this, "cancel"));
            btnCancel.addActionListener(this);
            btnCancel.setBounds(new java.awt.Rectangle(185, 292, 106, 26));
        }

        return btnCancel;
    }

    /**
     * This method initializes btnOk
     * @return 
     *
     * @return javax.swing.JButton
     */
    protected JButton getBtnOk() {
        if (btnOk == null) {
            btnOk = new JButton();
            btnOk.setText(PluginServices.getText(this, "ok"));
            btnOk.addActionListener(this);
            btnOk.setBounds(new java.awt.Rectangle(70, 292, 106, 26));
            return btnOk;
        }

        return btnOk;
    }

    /**
     * This method initializes pnlParam
     *
     * @return javax.swing.JPanel
     */
    protected JPanel getPnlParam() {
        if (pnlParam == null) {
            lblCapsLock = new JLabel();
            lblCapsLock.setBounds(new Rectangle(189, 249, 130, 20));
            lblCapsLock.setText("");
            lblConnName = new JLabel();
            lblConnName.setBounds(new java.awt.Rectangle(10, 30, 141, 21));
            lblConnName.setText(PluginServices.getText(this, "connection_name") +
                ":");
            lblConnected = new JLabel();
            lblConnected.setBounds(new java.awt.Rectangle(10, 247, 141, 21));
            lblConnected.setText(PluginServices.getText(this, "connected") +
                ":");
            lblUrl = new JLabel();
            lblUrl.setBounds(new java.awt.Rectangle(10, 80, 141, 21));
            lblUrl.setText(PluginServices.getText(this, "server_url") + ":");
            lblPass = new JLabel();
            lblPass.setBounds(new java.awt.Rectangle(10, 222, 141, 21));
            lblPass.setText(PluginServices.getText(this, "password") + ":");
            lblUser = new JLabel();
            lblUser.setBounds(new java.awt.Rectangle(10, 197, 141, 21));
            lblUser.setText(PluginServices.getText(this, "user") + ":");
            lblDatabase = new JLabel();
            lblDatabase.setBounds(new java.awt.Rectangle(10, 130, 141, 21));
            lblDatabase.setText(PluginServices.getText(this, "database_name") +
                ":");
            lblWarning = new JLabel();
            lblWarning.setBounds(new java.awt.Rectangle(10, 155, 310, 41));
            lblWarning.setText(PluginServices.getText(this, "warning_you_must_input_the_exact_name_this_difference_between_capital_letters_and_small_letters")
                );

            lblPort = new JLabel();
            lblPort.setBounds(new java.awt.Rectangle(10, 105, 141, 21));
            lblPort.setText(PluginServices.getText(this, "port") + ":");
            lblDriver = new JLabel();
            lblDriver.setBounds(new java.awt.Rectangle(10, 55, 141, 21));
            lblDriver.setText(PluginServices.getText(this, "driver") + ":");
            pnlParam = new JPanel();
            pnlParam.setBounds(new java.awt.Rectangle(10, 10, 336, 273));
            pnlParam.setBorder(javax.swing.BorderFactory.createTitledBorder(
                    null, PluginServices.getText(this, "connection_params"),
                    javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
                    javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
            pnlParam.setLayout(null);
            pnlParam.add(getTxfPort(), null);
            pnlParam.add(getCbxDriver(), null);
            pnlParam.add(getTxfDatabase(), null);
            pnlParam.add(gettxfUser(), null);
            pnlParam.add(getPwdPass(), null);
            pnlParam.add(lblDriver, null);
            pnlParam.add(lblPort, null);
            pnlParam.add(lblDatabase, null);
            pnlParam.add(lblWarning, null);
            pnlParam.add(lblUser, null);
            pnlParam.add(lblPass, null);
            pnlParam.add(getUrlTextArea(), null);
            pnlParam.add(lblUrl, null);
            pnlParam.add(getckbConnected(), null);
            pnlParam.add(lblConnected, null);
            pnlParam.add(lblConnName, null);
            pnlParam.add(getTxfConnName(), null);
            pnlParam.add(lblCapsLock, null);
        }

        return pnlParam;
    }

    /**
     * This method initializes cbxDriver
     *
     * @return javax.swing.JComboBox
     */
    private JComboBox getCbxDriver() {
        if (cbxDriver == null) {
            cbxDriver = new JComboBox();
            cbxDriver.addActionListener(this);
            cbxDriver.setEnabled(false);

            String[] drvName = getDriverNames();

            for (int i = 0; i < drvName.length; i++)
                cbxDriver.addItem(drvName[i]);

            cbxDriver.setBounds(new java.awt.Rectangle(155, 55, 166, 21));
            cbxDriver.setSelectedItem("PostGIS JDBC Driver");
        }

        return cbxDriver;
    }

    /**
     * This method initializes txfPort
     *
     * @return javax.swing.JTextField
     */
    protected JTextField getTxfPort() {
        if (txfPort == null) {
            txfPort = new JTextField();
            txfPort.addKeyListener(this);
            txfPort.setBounds(new java.awt.Rectangle(155, 105, 166, 21));
            txfPort.setText("5432");
            txfPort.setEnabled(false);
        }

        return txfPort;
    }

    /**
     * This method initializes txfDatabase
     *
     * @return javax.swing.JTextField
     */
    protected JTextField getTxfDatabase() {
        if (txfDatabase == null) {
            txfDatabase = new JTextField();
            txfDatabase.addKeyListener(this);
            txfDatabase.setBounds(new java.awt.Rectangle(155, 130, 166, 21));
            txfDatabase.setText("database_name");
            txfDatabase.setEnabled(false);
        }

        return txfDatabase;
    }

    /**
     * This method initializes txfUser
     *
     * @return javax.swing.JTextField
     */
    private JTextField gettxfUser() {
        if (txfUser == null) {
            txfUser = new JTextField();
            txfUser.addKeyListener(this);
           
            txfUser.setBounds(new java.awt.Rectangle(155, 197, 166, 21));
            txfUser.setText("admin");
            txfUser.getDocument().addDocumentListener(
                    new DocumentListener() {
                        public void changedUpdate(DocumentEvent e) {
                            txfConnName.setText(txfUser.getText());
                        }
                        public void insertUpdate(DocumentEvent e) {
                            txfConnName.setText(txfUser.getText());

                        }
                        public void removeUpdate(DocumentEvent e) {
                            txfConnName.setText(txfUser.getText());

                        }
                    });
        }

        return txfUser;
    }

    /**
     * This method initializes pwdPass
     *
     * @return javax.swing.JPasswordField
     */
    protected JPasswordField getPwdPass() {
        if (pwdPass == null) {
            pwdPass = new JPasswordField();
            pwdPass.addKeyListener(this);
            pwdPass.setBounds(new java.awt.Rectangle(155, 222, 166, 21));
            pwdPass.setText("admin");
            pwdPass.addKeyListener(new java.awt.event.KeyAdapter() {
            	public void keyReleased(java.awt.event.KeyEvent e) {
            		 boolean state= Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);  
				      if(state == true){
				      	lblCapsLock.setText("<HTML><FONT COLOR = Red>CapsLock is ON.</FONT></HTML>");
				      	pwdPass.setText("");
				      	pwdPass.requestFocus();
				      }
				      else 
				    	  lblCapsLock.setText("");            	}
            });
        }

        return pwdPass;
    }
    protected void Login() {
		try{
		strDatabaseUser = new String(txfUser.getText().trim());
		strDatabasePass = new String(pwdPass.getPassword()).trim();
		if(strDatabaseUser.equals("")) // If password and username is empty > Do this >>>
			
		{
		JLabel errorFields = new JLabel("<HTML><FONT COLOR = Black>Hãy nhập tài khoản.</FONT></HTML>");
		JOptionPane.showMessageDialog(null,errorFields);
		txfUser.requestFocus();
		
		
			}
		else if(strDatabasePass.equals("")) // If password and username is empty > Do this >>>
			
		{
		JLabel errorFields = new JLabel("<HTML><FONT COLOR = Black>Hãy nhập mật khẩu.</FONT></HTML>");
		JOptionPane.showMessageDialog(null,errorFields);
		pwdPass.requestFocus();
					
		}
}
		catch(Exception e1) {
			pwdPass.setText("");
			txfUser.requestFocus();
			strDatabaseUser ="";
			strDatabasePass="";
		
		}
		
		
	}
    protected String[] getDriverNames() {
        Class[] classes = new Class[] { IVectorialDatabaseDriver.class };

        ArrayList ret = new ArrayList();
        String[] driverNames = LayerFactory.getDM().getDriverNames();

        for (int i = 0; i < driverNames.length; i++) {
            for (int j = 0; j < classes.length; j++) {
                if (LayerFactory.getDM().isA(driverNames[i], classes[j])) {
                    ret.add(driverNames[i]);
                }
            }
        }

        return (String[]) ret.toArray(new String[0]);
    }

    public void actionPerformed(ActionEvent arg0) {
        Object src = arg0.getSource();

        if (src == ckbConnected) {
            if (ckbConnected.isSelected()) {
                pwdPass.setEnabled(true);
                pwdPass.setBackground(Color.WHITE);
            }
            else {
                pwdPass.setText("");
                pwdPass.setEnabled(false);
                pwdPass.setBackground(Color.LIGHT_GRAY);
            }
        }

        if (src == btnOk) {
            blnOkPressed = true;
           
            if (isblnOkPressed()) {
                String _drvname = getConnectionDriverName();
                String _host = getConnectionServerUrl();
                String _port = getConnectionPort();
                String _dbname = getConnectionDBName();
                String _user = getConnectionUser();
                String _pw = getConnectionPassword();
                String _conn_usr_name = getConnectionName();
                strConnName= getConnectionName();
                strDatabaseName=getConnectionDBName();
                strHost= getConnectionServerUrl();
                //strDatabaseUser = getConnectionUser();
                //strDatabasePass=getConnectionPassword();
                strDriver=getConnectionDriverName();
                strPort=getConnectionPort();
                strDatabaseUrl=strPrefixPgUrl+strHost+"/" +strDatabaseName;

                boolean hasToBeCon = hasToBeConnected();
   
                
                strDatabaseUser = new String(txfUser.getText().trim());
        		strDatabasePass = new String(pwdPass.getPassword()).trim();
        		if(strDatabaseUser.equals("")) // If password and username is empty > Do this >>>
        			
        		{
        		JLabel errorFields = new JLabel("<HTML><FONT COLOR = Black>Hãy nhập tài khoản.</FONT></HTML>");
        		JOptionPane.showMessageDialog(null,errorFields);
        		txfUser.requestFocus();
        		
        		
        			}
        		else if(strDatabasePass.equals("")) // If password and username is empty > Do this >>>
        			
        		{
        		JLabel errorFields = new JLabel("<HTML><FONT COLOR = Black>Hãy nhập mật khẩu.</FONT></HTML>");
        		JOptionPane.showMessageDialog(null,errorFields);
        		pwdPass.requestFocus();
        					
        		}
                else 
//                try 
//        		{
                	connectionManager=new GiscConnectionBuilder()
                	.Db(_dbname)
                	.User(_user)
                	.Pass(_pw)
                	.Name(_conn_usr_name)
                	.BuildConnection();
//                	connectionManager.AddConnection(_drvname, _port, _host, _dbname, _user, _pw,
//                        _conn_usr_name, hasToBeCon);
//                	connectionManager.AddConnection(_drvname, _port, _host, _dbname, _user, _pw,
//                        _conn_usr_name, hasToBeCon);
        		if(connectionManager.IsSuccess())
        		{
               	 	PluginServices.getMDIManager().closeWindow(this);
        		}
//                }
//                catch (DBException e) {
//                	strDatabaseUser ="";
//        			strDatabasePass="";
//                    showConnectionErrorMessage(e.getMessage(), false);
//                    
//                }
            }
            saveConnections();
            return;
        }

        
        if (src == btnCancel) {
            blnOkPressed = false;
            strDatabaseUser ="";
			strDatabasePass="";
            PluginServices.getMDIManager().closeWindow(this);

            return;
        }

        if (src == cbxDriver) {
            String driverName = cbxDriver.getSelectedItem().toString();
            IVectorialDatabaseDriver driver;

            try {
                driver = (IVectorialDatabaseDriver) LayerFactory.getDM()
                                                           .getDriver(driverName);
                txfPort.setText("" + driver.getDefaultPort());
            }
            catch (DriverLoadException e1) {
                txfPort.setText("");
            }

            return;
        }
    }
    protected void saveConnections(){
    	if (this.sglDBConnection == null){
    		this.sglDBConnection = (SingleVectorialDBConnectionExtension) PluginServices.getExtension(SingleVectorialDBConnectionExtension.class);
    	}
    	SingleVectorialDBConnectionExtension.saveAllToPersistence();

    }
    protected void showConnectionErrorMessage(String _msg, boolean reconnect) {
        String msg = (_msg.length() > 300) ? "" : (": " + _msg);
        String title = "";

        if (reconnect) {
            title = PluginServices.getText(this, "reconnection_error");
        }
        else {
            title = PluginServices.getText(this, "connection_error");
        }

        JOptionPane.showMessageDialog(this, title + msg, title,
            JOptionPane.ERROR_MESSAGE);
    }
    public boolean isblnOkPressed() {
        return blnOkPressed;
    }

    public boolean hasToBeConnected() {
        return ckbConnected.isSelected();
    }

    protected String getConnectionDriverName() {
        return cbxDriver.getSelectedItem().toString();
    }

    protected String getConnectionServerUrl() {
        return txfUrl.getText();
    }

    protected String getConnectionPort() {
        return txfPort.getText();
    }

    protected String getConnectionDBName() {
        return txfDatabase.getText();
    }

    protected String getConnectionUser() {
        return txfUser.getText();
    }

    protected String getConnectionPassword() {
        return new String(pwdPass.getPassword());

    }
    
    

    protected JTextField getUrlTextArea() {
        if (txfUrl == null) {
            txfUrl = new JTextField();
            txfUrl.addKeyListener(this);
            txfUrl.setBounds(new java.awt.Rectangle(155, 80, 166, 21));
            txfUrl.setText("localhost");
            txfUrl.setEnabled(false);
        }

        return txfUrl;
    }

    /**
     * This method initializes ckbConnected
     *
     * @return javax.swing.JCheckBox
     */
    protected JCheckBox getckbConnected() {
        if (ckbConnected == null) {
            ckbConnected = new JCheckBox();
            ckbConnected.setSelected(true);
            ckbConnected.addActionListener(this);
            ckbConnected.setBounds(new java.awt.Rectangle(155, 247, 26, 21));
        }

        return ckbConnected;
    }

    public String getConnectionName() {
        return getTxfConnName().getText();
    }

    /**
     * This method initializes txfConnName
     *
     * @return javax.swing.JTextField
     */
    protected JTextField getTxfConnName() {
        if (txfConnName == null) {
            txfConnName = new JTextField();
            txfConnName.addKeyListener(this);
            txfConnName.setBounds(new java.awt.Rectangle(155, 30, 166, 21));
            txfConnName.setEnabled(false);
        }

        return txfConnName;
    }

    public void keyPressed(KeyEvent e) {
    }

    public void keyReleased(KeyEvent e) {
        if (e.getKeyChar() != '\n') {
            return;
        }

        Object src = e.getSource();

        if (src == pwdPass) {
            ActionEvent aevt = new ActionEvent(btnOk,
                    ActionEvent.ACTION_PERFORMED, "");
            actionPerformed(aevt);
        }
        else {
            if (src instanceof JTextField) {
                ((JTextField) src).transferFocus();
            }
        }
    }

    public void keyTyped(KeyEvent e) {
    }

    public void loadValues(ConnectionWithParams cwp) {
        getTxfPort().setText(cwp.getPort());
        selectThisInDriverCombo(cwp.getDrvName());
        getTxfDatabase().setText(cwp.getDb());
        gettxfUser().setText(cwp.getUser());
       
        if (cwp.getPw() == null) {
            getPwdPass().setText("");
        }
        else {
            getPwdPass().setText(cwp.getPw());
        }

        getUrlTextArea().setText(cwp.getHost());

        boolean connected = false;

        try {
            connected = (cwp.getConnection() != null) &&
                (!cwp.getConnection().isClosed());
        }
        catch (DBException e) {
            logger.error("While checking connection: " + e.getMessage());
            connected = false;
        }

        getckbConnected().setSelected(connected);
        getTxfConnName().setText(cwp.getName());
    }

    protected void selectThisInDriverCombo(String drvName) {
        int size = getCbxDriver().getItemCount();

        for (int i = 0; i < size; i++) {
            Object item = getCbxDriver().getItemAt(i);

            if (item.toString().compareToIgnoreCase(drvName) == 0) {
                getCbxDriver().setSelectedIndex(i);

                return;
            }
        }
    }

	public Object getWindowProfile() {
		return WindowInfo.DIALOG_PROFILE;
	}
	protected void addConnection(String _drvName, String _port, String _host,
		        String _dbName, String _user, String _pw, String _conn_usr_name,
		        boolean is_conn) throws DBException {
		        SingleVectorialDBConnectionManager.instance()
		                                   .getConnection(_drvName, _user, _pw,
		            _conn_usr_name, _host, _port, _dbName, is_conn);

		       // refreshTree();
	}
	
	/**
	 * Dùng cho các form Login con. Gán tên cho database
	 * @param name
	 * @author HT
	 */
	protected void setDatabaseName(String name)
	{
		txfDatabase.setText(name);
	}
	/**
	 * Dùng cho các form Login con. Gán tên cho server url
	 * @param url (ví dụ: localhost)
	 * @author HT
	 */
	protected void setUrl(String url)
	{
		txfUrl.setText(url);
	}
	/**
	 * Dùng cho các form Login con. Gán tên cho user name
	 * @param user=admin
	 * @author HT
	 */
	protected void setUser(String user)
	{
		txfUser.setText(user);
	}
	/**
	 * Dùng cho các form Login con. Gán tên cho Password
	 * @param pass
	 * @author HT
	 */
	protected void setPass(String pass)
	{
		pwdPass.setText(pass);
	}

	/* (non-Javadoc)
	 * @see gisc.gov.vn.projectX.gui.HForm#showDialog()
	 */
//	@Override
	public void showDialog() {
		// TODO Auto-generated method stub
		PluginServices.getMDIManager().addCentredWindow(this);
	}

	/* (non-Javadoc)
	 * @see gisc.gov.vn.projectX.gui.ITempLoginForm#GetUser()
	 */
//	@Override
//	public String GetUser() {
//		// TODO Auto-generated method stub
//		return this.strDatabaseUser;
//	}
//
//	/* (non-Javadoc)
//	 * @see gisc.gov.vn.projectX.gui.ITempLoginForm#GetPass()
//	 */
//	@Override
//	public String GetPass() {
//		// TODO Auto-generated method stub
//		return this.strDatabasePass;
//	}
//
//	/* (non-Javadoc)
//	 * @see gisc.gov.vn.projectX.gui.ITempLoginForm#GetDatabaseName()
//	 */
//	@Override
//	public String GetDatabaseName() {
//		// TODO Auto-generated method stub
//		return this.strDatabaseName;
//	}
//
//	/* (non-Javadoc)
//	 * @see gisc.gov.vn.projectX.gui.ITempLoginForm#GetUrl()
//	 */
//	@Override
//	public String GetUrl() {
//		// TODO Auto-generated method stub
//		return this.strDatabaseUrl;
//	}
	
//	public String GetDatabaseUrl()
//    {
//    	return this.strDatabaseUrl;
//    }
//
//	/* (non-Javadoc)
//	 * @see gisc.gov.vn.projectX.gui.ITempLoginForm#GetPort()
//	 */
//	@Override
//	public String GetPort() {
//		// TODO Auto-generated method stub
//		return this.strPort;
//	}
//
//	/* (non-Javadoc)
//	 * @see gisc.gov.vn.projectX.gui.ITempLoginForm#GetDriver()
//	 */
//	@Override
//	public String GetDriver() {
//		// TODO Auto-generated method stub
//		return this.strDriver;
//	}
//
//	/* (non-Javadoc)
//	 * @see gisc.gov.vn.projectX.gui.ITempLoginForm#GetConnName()
//	 */
//	@Override
//	public String GetConnName() {
//		// TODO Auto-generated method stub
//		return this.strConnName;
//	}
//
//	/* (non-Javadoc)
//	 * @see gisc.gov.vn.projectX.gui.ITempLoginForm#IsConnected()
//	 */
//	@Override
//	public Boolean IsConnected() {
//		// TODO Auto-generated method stub
//		return this.blnIsConnected;
//	}
//
//	/* (non-Javadoc)
//	 * @see gisc.gov.vn.projectX.gui.ITempLoginForm#SetUser(java.lang.String)
//	 */
//	@Override
//	public void SetUser(String user) {
//		// TODO Auto-generated method stub
//		this.strDatabaseUser=user;
//	}
//
//	/* (non-Javadoc)
//	 * @see gisc.gov.vn.projectX.gui.ITempLoginForm#SetPass(java.lang.String)
//	 */
//	@Override
//	public void SetPass(String pass) {
//		// TODO Auto-generated method stub
//		this.strDatabasePass=pass;
//	}
//
//	/* (non-Javadoc)
//	 * @see gisc.gov.vn.projectX.gui.ITempLoginForm#SetDatabaseName(java.lang.String)
//	 */
//	@Override
//	public void SetDatabaseName(String DBname) {
//		// TODO Auto-generated method stub
//		this.strDatabaseName=DBname;
//	}
//
//	/* (non-Javadoc)
//	 * @see gisc.gov.vn.projectX.gui.ITempLoginForm#SetUrl(java.lang.String)
//	 */
//	@Override
//	public void SetUrl(String url) {
//		// TODO Auto-generated method stub
//		this.strDatabaseUrl=url;
//	}
//
//	/* (non-Javadoc)
//	 * @see gisc.gov.vn.projectX.gui.ITempLoginForm#SetPort(java.lang.String)
//	 */
//	@Override
//	public void SetPort(String port) {
//		// TODO Auto-generated method stub
//		this.strPort=port;
//	}
//
//	/* (non-Javadoc)
//	 * @see gisc.gov.vn.projectX.gui.ITempLoginForm#SetDriver(java.lang.String)
//	 */
//	@Override
//	public void SetDriver(String driver) {
//		// TODO Auto-generated method stub
//		this.strDriver=driver;
//	}
//
//	/* (non-Javadoc)
//	 * @see gisc.gov.vn.projectX.gui.ITempLoginForm#SetConnName(java.lang.String)
//	 */
//	@Override
//	public void SetConnName(String name) {
//		// TODO Auto-generated method stub
//		this.strConnName=name;
//	}
//
//	/* (non-Javadoc)
//	 * @see gisc.gov.vn.projectX.gui.ITempLoginForm#SetIsConnected(java.lang.Boolean)
//	 */
//	@Override
//	public void SetIsConnected(Boolean isConnected) {
//		// TODO Auto-generated method stub
//		this.blnIsConnected=isConnected;
//	}
//
//	/* (non-Javadoc)
//	 * @see gisc.gov.vn.projectX.gui.ITempLoginForm#ShowDialog()
//	 */
//	@Override
//	public void ShowDialog() {
//		// TODO Auto-generated method stub
//		PluginServices.getMDIManager().addCentredWindow(this);
//	}
	/* (non-Javadoc)
	 * @see gisc.gov.vn.dev.core.IGiscSingletonInfo#Existed()
	 */
	@Override
	public Boolean Exist() {
		// TODO Auto-generated method stub
		return this.exist;
	}

	/* (non-Javadoc)
	 * @see gisc.gov.vn.dev.core.IGiscSingletonInfo#GetDbUserName()
	 */
	@Override
	public String GetDbUserName() {
		// TODO Auto-generated method stub
		return this.strDatabaseUser;
	}

	/* (non-Javadoc)
	 * @see gisc.gov.vn.dev.core.IGiscSingletonInfo#GetDbPass()
	 */
	@Override
	public String GetDbPass() {
		// TODO Auto-generated method stub
		return this.strDatabasePass;
	}

	/* (non-Javadoc)
	 * @see gisc.gov.vn.dev.core.IGiscSingletonInfo#GetDbHost()
	 */
	@Override
	public String GetDbHost() {
		// TODO Auto-generated method stub
		return this.strHost;
	}

	/* (non-Javadoc)
	 * @see gisc.gov.vn.dev.core.IGiscSingletonInfo#GetDbPort()
	 */
	@Override
	public String GetDbPort() {
		// TODO Auto-generated method stub
		return this.strPort;
	}

	/* (non-Javadoc)
	 * @see gisc.gov.vn.dev.core.IGiscSingletonInfo#GetDbDriver()
	 */
	@Override
	public String GetDbDriver() {
		// TODO Auto-generated method stub
		return this.strDriver;
	}

	/* (non-Javadoc)
	 * @see gisc.gov.vn.dev.core.IGiscSingletonInfo#GetDbUrl()
	 */
	@Override
	public String GetDbUrl() {
		// TODO Auto-generated method stub
		return this.strDatabaseUrl;
	}

	@Override
	public String GetDbName() {
		// TODO Auto-generated method stub
		return this.strDatabaseName;
	}

		   

}
